package conf

import (
	"fmt"
	"github.com/spf13/viper"
)

type Config struct {
	MySqlConfig
}

type MySqlConfig struct {
	User     string
	Password string
	Host     string
	Port     int
	Data     string
}

var AppConf Config

func Init() {
	viper.SetConfigFile("./conf/conf.yaml")
	if err := viper.ReadInConfig(); err != nil {
		fmt.Println("配置文件读取失败")
		return
	}
	if err := viper.Unmarshal(&AppConf); err != nil {
		fmt.Println("配置文件解析失败")
		return
	}
	fmt.Println("配置文件读取成功")
}
